package com.loong.game2048.server.impl;

import com.loong.game2048.dao.PictureDao;
import com.loong.game2048.module.Picture;
import com.loong.game2048.server.PictureServer;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@Service
public class PictureServerImpl implements PictureServer {

    @Resource
    private PictureDao pictureDao;

    @Override
    public void addPicture(Picture picture) {
        pictureDao.addPicture(picture);
    }

    @Override
    public List<Picture> findByFid(Integer id) {
        return pictureDao.findByFid(id);
    }

    @Override
    public List<String> findByFidOnlyName(Integer id) {
        return pictureDao.findByFidOnlyName(id);
    }


    @Override
    public void addPictures(List<String> pictures, Integer fid) {
        for (String picName : pictures) {
            Picture picture = new Picture();
            picture.setF_id(fid);
            picture.setP_name(picName);
            pictureDao.addPicture(picture);
        }
    }

    @Override
    public void deleteByFid(Integer id) {
        pictureDao.deleteByFid(id);
    }

    @Override
    public void deleteByNameAndFid(String dbPicName, Integer id) {
        pictureDao.deleteByNameAndFid(dbPicName,id);
    }


}
